﻿using Sgr.Domain.Repositories;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.DataCategories.Domain.AdministrativeDivisions
{
    /// <summary>
    /// 行政区划仓储接口
    /// </summary>
    public interface IAdministrativeDivisionRepository : ITreeNodeBaseRepositoryOfTEntityAndTPrimaryKey<AdministrativeDivision, long>
    {
        /// <summary>
        /// 根据行政区划代码获取行政区划
        /// </summary>
        /// <param name="code">行政区划代码</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>行政区划</returns>
        Task<AdministrativeDivision?> GetByCodeAsync(string code, CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据行政区划级别获取行政区划列表
        /// </summary>
        /// <param name="level">行政区划级别</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>行政区划列表</returns>
        Task<IEnumerable<AdministrativeDivision>> GetByLevelAsync(int level, CancellationToken cancellationToken = default);

        /// <summary>
        /// 检查行政区划代码是否唯一
        /// </summary>
        /// <param name="code">行政区划代码</param>
        /// <param name="excludeId">需要排除的ID</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>是否存在</returns>
        Task<bool> CodeIsUniqueAsync(string code, long? excludeId = null, CancellationToken cancellationToken = default);
    }
}